// 导入定义验证规则的包
const joi = require('joi')

// 定义用户名和密码的验证规则 required()：必填
const username = joi.string().alphanum().min(1).max(10).required()
const password = joi.string().pattern(/^[\S]{6,12}$/).required()
const code = joi.string().required()
// 修改信息的验证规则
const id = joi.number().integer().min(1).required()
const nickname = joi.string().required()
const email = joi.string().email().required()
// dataUri()验证是不是base64
const avatar = joi.string().dataUri().required()
exports.reg_login_schema = {
	body:{
		username,
		password
	}
}
exports.reg_reg_schema = {
	body:{
		username,
		password,
		mail:email,
		code
	}
}
exports.update_userinfo_schema = {
	body:{
		user_id:id,
		nickname,
		email
	}
}
exports.update_password_schema = {
	body:{
		oldPwd:password,
		newPwd:joi.not(joi.ref('oldPwd')).concat(password)
	}
}
exports.update_avatar_schema = {
	body:{
		avatar
	}
}